package com.laowang.project.system.controller;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.laowang.framework.aspectj.lang.annotation.Log;
import com.laowang.framework.aspectj.lang.enums.BusinessType;

import org.springframework.web.bind.annotation.*;
import com.laowang.project.system.domain.MyCyhWelfare;
import com.laowang.project.system.service.MyCyhWelfareService;
import com.laowang.framework.web.controller.BaseController;
import com.laowang.framework.web.domain.AjaxResult;
import com.laowang.common.utils.poi.ExcelUtil;
import com.laowang.framework.web.page.TableDataInfo;

/**
 * H5福利待遇Controller
 * 
 * @author laowang
 * @date 2023-10-16
 */
@Api(tags = "H5福利待遇接口")
@RestController
@RequestMapping("/welfare")
public class MyCyhWelfareController extends BaseController {
    @Autowired
    private MyCyhWelfareService myCyhWelfareService;

    /**
     * 查询H5福利待遇列表
     */
    @ApiOperation(value = "网页端 查询H5福利待遇列表",notes = "")
    @GetMapping("/h5")
    public AjaxResult h5list() {

        MyCyhWelfare myCyhWelfare = myCyhWelfareService.selectMyCyhWelfareById(1);
        return AjaxResult.success("操作成功",myCyhWelfare);
    }

    /**
     * 查询H5福利待遇列表
     */
    @ApiOperation(value = "查询H5福利待遇列表",notes = "")
    @PreAuthorize("@ss.hasPermi('my:welfare:list')")
    @GetMapping("/list")
        public TableDataInfo list(MyCyhWelfare myCyhWelfare) {
        startPage();
        List<MyCyhWelfare> list = myCyhWelfareService.selectMyCyhWelfareList(myCyhWelfare);
        return getDataTable(list);
    }
    
    /**
     * 导出H5福利待遇列表
     */
    @ApiOperation(value = "导出H5福利待遇列表",notes = "")
    @PreAuthorize("@ss.hasPermi('my:welfare:export')")
    @Log(title = "H5福利待遇", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MyCyhWelfare myCyhWelfare) {
        List<MyCyhWelfare> list = myCyhWelfareService.selectMyCyhWelfareList(myCyhWelfare);
        ExcelUtil<MyCyhWelfare> util = new ExcelUtil<MyCyhWelfare>(MyCyhWelfare.class);
        return util.exportExcel(list, "welfare");
    }

    /**
     * 获取H5福利待遇详细信息
     */
    @ApiOperation(value = "获取H5福利待遇详细信息",notes = "")
    @PreAuthorize("@ss.hasPermi('my:welfare:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id) {
        return AjaxResult.success(myCyhWelfareService.selectMyCyhWelfareById(id));
    }

    /**
     * 新增H5福利待遇
     */
    @ApiOperation(value = "新增H5福利待遇",notes = "")
    @PreAuthorize("@ss.hasPermi('my:welfare:add')")
    @Log(title = "H5福利待遇", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MyCyhWelfare myCyhWelfare) {
        return toAjax(myCyhWelfareService.insertMyCyhWelfare(myCyhWelfare));
    }

    /**
     * 修改H5福利待遇
     */
    @ApiOperation(value = "修改H5福利待遇",notes = "")
    @PreAuthorize("@ss.hasPermi('my:welfare:edit')")
    @Log(title = "H5福利待遇", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MyCyhWelfare myCyhWelfare) {
        return toAjax(myCyhWelfareService.updateMyCyhWelfare(myCyhWelfare));
    }

    /**
     * 删除H5福利待遇
     */
    @ApiOperation(value = "删除H5福利待遇",notes = "")
    @PreAuthorize("@ss.hasPermi('my:welfare:remove')")
    @Log(title = "H5福利待遇", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids) {
        return toAjax(myCyhWelfareService.deleteMyCyhWelfareByIds(ids));
    }
}
